package io.xiaojl.xj2ee.modules.sys.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import io.xiaojl.xj2ee.common.kit.PageWrapper;
import io.xiaojl.xj2ee.modules.sys.entity.SysDictEntity;
import io.xiaojl.xj2ee.modules.sys.mapper.SysDictEntityMapper;
import io.xiaojl.xj2ee.modules.sys.service.SysDictService;


@Service("sysDictService")
public class SysDictServiceImpl implements SysDictService {
	@Autowired
	private SysDictEntityMapper baseMapper;
    @Override
    public PageWrapper<SysDictEntity> queryPage(Map<String, Object> params) {
    	PageWrapper<SysDictEntity> pw = new PageWrapper<>(params);
		PageHelper.startPage(pw.getCurrPage(), pw.getPageSize(), pw.getOrderBy());
		
		List<SysDictEntity> list = baseMapper.selectListByPage(pw.getCondition());
		PageInfo<SysDictEntity> page = new PageInfo<>(list);
		
		pw.setList(page.getList());
		pw.setTotalCount(Integer.parseInt(page.getTotal()+""));
		pw.setTotalPage(page.getPages());
        return pw;
    }
	@Override
	public SysDictEntity selectById(Long id) {
		return baseMapper.selectByPrimaryKey(id);
	}
	@Override
	public int insert(SysDictEntity dict) {
		return baseMapper.insertSelective(dict);
	}
	@Override
	public int updateById(SysDictEntity dict) {
		return baseMapper.updateByPrimaryKey(dict);
	}
	@Override
	public int deleteBatchIds(Long[] ids) {
		return baseMapper.deleteBatchIds(ids);
	}

}
